﻿@model Vizzio.Models.Pedido
@{
    ViewBag.Title = "DespacharProductos";
    var tipoPedido = Model.Tipo;
    var numeroPedido = Model.PedidoID;
    var Productos = ViewBag.productos as List<Vizzio.Models.ProductoDePedido>;
}

<h2>Despachar productos de pedido</h2>

@using (Html.BeginForm())
{

    <div class="form-horizontal contendedor_principal">
        <h4><strong>Pedido Nº @numeroPedido de @tipoPedido</strong></h4>
        <hr />
        @Html.ValidationSummary(true)
        <div class="control-group form-group" id="divSocios">
            <label class="control-label col-md-2 control-label">Socio</label>
            <div class="col-md-10">
                <input class="form-control" disabled="" type="text" placeholder="@ViewBag.nombreSocio">
            </div>
        </div>

        <div class="control-group form-group">
            @Html.LabelFor(model => model.Fecha, "* Fecha de Pedido", new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                <div class="input-group date">
                    <span class="input-group-addon"><i class="glyphicon glyphicon-th"></i></span><input type="text" name="Fecha" class="form-control" readonly value="@DateTime.Now.Date.ToShortDateString()">
                </div>
            </div>
        </div>
        <div class="control-group form-group">
            <label class="control-label col-md-2" for="disabledInput">Estado</label>
            <div class="col-md-10">
                <input class="form-control" id="disabledInputEstado" placeholder="Pendiente" disabled="" type="text">
            </div>
        </div>
        <hr />
        <div class="row">
            <div class="col-md-12">
                <table class="table table-striped table-hover">
                    <thead>
                        <tr>
                            <th>
                                @Html.DisplayName("Nombre")
                            </th>
                            <th>
                                @Html.DisplayName("Empresa")
                            </th>
                            <th>
                                @Html.DisplayName("Presentacion")
                            </th>
                            <th>
                                @Html.DisplayName("Cantidad")
                            </th>
                            <th>
                                @Html.DisplayName("Costo")
                            </th>
                            <th>
                                @Html.DisplayName("Cantidad Despachada")
                            </th>
                        </tr>
                    </thead>
                    <tbody class="productos">
                        @{ int prodIndex = 0;}
                        @foreach (var item in Productos)
                        {

                            <tr>
                                <td>
                                    @Html.DisplayFor(modelItem => item.Nombre)
                                </td>
                                <td>
                                    @Html.DisplayFor(modelItem => item.Empresa)
                                </td>
                                <td>
                                    @Html.DisplayFor(modelItem => item.Presentacion)
                                </td>
                                <td>
                                    @Html.DisplayFor(modelItem => item.Cantidad)
                                </td>
                                <td>
                                    @Html.DisplayFor(modelItem => item.Costo)
                                </td>
                                <td><div class='control-group'><div class='controls'><input type="text" hidden="" name="SalidaPorPedido[@prodIndex].PedidoID" value="@Html.DisplayFor(modelItem => item.pedidoID)" /><div class='controls'><input type="text" hidden="" name="SalidaPorPedido[@prodIndex].ProductoID" value="@Html.DisplayFor(modelItem => item.productoID)" /><input name="SalidaPorPedido[@prodIndex].cantidad" type='text' class="form-control cantidad" data-validation-number-message='Solo numeros enteros' required data-validation-required-message='Campo requerido' min='0' data-validation-min-message='Debe ser mayor o igual a cero' maxlength='6' data-validation-maxlength-message='Muy grande. Maximo 6 digitos' data-validation-regex-regex='[0-9]+' data-validation-regex-message='Debe ingresar un entero positivo' placeholder='Cantidad' /><p class='help-block'></p></div></div></td>
                            </tr>
                            prodIndex = prodIndex + 1;
                        }
                    </tbody>
                </table>
            </div>
        </div>
        <hr />

        <div class="form-group row">
            <div class="col-md-offset-2 col-md-1">
                <button type="submit" class="btn btn-primary" id="btnRegistrar">
                    <span class="glyphicon glyphicon-ok"></span> Registrar
                </button>
            </div>
            <div class="col-md-offset-1 col-md-1">
                <a href="@Url.Action("Index", "Pedido")" class="btn btn-primary">
                    <span class="glyphicon glyphicon-remove"></span> Cancelar
                </a>
            </div>
        </div>
    </div>
}
@section Scripts {
    <script>
        $(function () { $("input,select,textarea").not("[type=submit]").jqBootstrapValidation(); });
    </script>
    @Scripts.Render("~/bundles/jqueryval")
}




